<!--#include file="Config.asp" -->
<!--#include file="HeadTop.asp"-->

<%

userid=session("AnyPIM_userID")

if isempty(request("eid"))=false then
   sql="select * from Contact_Group where userid='"&userid&"' and gid="&request("eid")
   set rs=server.createobject("adodb.recordset")
   rs.open sql,conn,1,1
   agroup=rs("agroup")
   rs.close
end if

if isempty(request("newgrpname1"))=false and trim(request("newgrpname1"))<>"" then
 sql="update Contact_Group set agroup='"&request("newgrpname1")&"' where userid='"&userid&"' and agroup='"&request("agroup")&"'"
 conn.execute(sql)
 info="组名修改成功！"
end if

if isempty(request("newgrpname"))=false and trim(request("newgrpname"))<>"" then
 set rs=server.createobject("adodb.recordset")
 sql="select * from Contact_Group where userid='"&userid&"' and agroup='"&request("newgrpname")&"'"
 rs.open sql,conn,1,1

 if not rs.eof then
   info="对不起，你输入的组名已存在！"
   rs.close
  else
   rs.close
   sql="select * from Contact_Group "
   rs.open sql,conn,3,3
   rs.addnew()
   rs("userid")=userid
   rs("agroup")=request("newgrpname")
   info="组名添加成功！"
   rs.update
   rs.close
   end  if
end if

%>


<table class="table table-condensed">
<TR>
<TD noWrap vAlign='top'>


<table class="table table-condensed table-bordered">
<TR bgcolor='#ccff99'>
<FORM action="?" method=post name=group>
    <TD>
      <%if isempty(request("eid")) then%>
	  请输入组名建立新组，不可以重名&nbsp;
	  <INPUT class=flat1a name=newgrpname   size='40'>
     <%else%>
  	  我要将旧组名<FONT color=#ff0000><%=agroup%></FONT>改名成
       <input type=hidden name=agroup value=<%=agroup%>>
	   <INPUT class=flat1a name=newgrpname1 size=40 value=<%=agroup%>  >
<%end if %><INPUT class=flat3 name=sub3 type=submit value=确定>
</TD></TR>
</TABLE>

<!--  -->
<table class="table table-condensed table-bordered">
<TR bgcolor='#ccff99'>
<TD>组名</TD>
    <TD>编辑</TD>
  </TR>
<%
sql="select * from Contact_Group where userid='"&userid&"'"
rs.open sql,conn,1,1
do while not rs.eof
%>

  <TR>
    <TD><%=rs("agroup")%></TD>
    <TD><A href="?eid=<%=rs("gid")%>">编辑</A></TD>
  </TR>
<%
rs.movenext
loop
rs.close
%>

</TABLE>


</TD>
<TD noWrap vAlign='top' width='10'></TD>
<TD noWrap vAlign='top' width='200'>
	<!-- 分组开始 -->
	<!--#include file=IncContactGroup.asp -->
	<!-- 分组结束 -->
</TD>
</TD>
</TR>

</TABLE>

<!--#include file=Foot.asp -->
